﻿using UnityEngine;
using System.Collections;

public class NGUIEventColor : MonoBehaviour {
	public ColorEvent Color;
	public float TestTime = 1;
	public ValueEvent.EaseType easyType;
	public WrapMode m_Wrap;
	public UIWidget Target;
	private float savetime;
	private float m_Speed;
	// Use this for initialization
	void Start () {
		if (Target == null)
			Target = GetComponent<UIWidget> ();
		if (Target == null)
			GameObject.Destroy (this);
	}
	public void Play(float m_Time){
		savetime = Time.time;
		m_Speed = 1 / m_Time;
	}
	public void Stop(){

	}
	// Update is called once per frame
	void Update () {
		float time = ValueEvent.WrapValue((Time.time - savetime)*m_Speed,0,1,m_Wrap);
		Target.color = Color.Lerp(easyType,time);
	}
}
